#ifndef COLORMARKER_H
#define COLORMARKER_H

#include <QObject>
#include <QColor>

class ColorMarker : public QObject
{
    Q_OBJECT
    Q_ENUMS(GenerateAlgorithm)
    Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
    Q_PROPERTY(QColor timeColor READ timeColor)

public:
    explicit ColorMarker(QObject *parent = 0);
    ~ColorMarker() {}

    enum GenerateAlgorithm{
        RandomRGB,
        RandomRed,
        RandomGreen,
        RandomBlue,
        LinearIncrease
    };
    QColor color() const;
    void setColor(const QColor& color);
    QColor timeColor() const;

    Q_INVOKABLE GenerateAlgorithm algorithm() const;
    Q_INVOKABLE void setAlgorithm(GenerateAlgorithm algorithm);
signals:
    void colorChanged(const QColor &color);
    void currentTime(const QString &strTime);
public slots:
    void start();
    void stop();

protected:
    void timerEvent(QTimerEvent *event);

private:
    GenerateAlgorithm m_algorithm;
    QColor m_curColor;
    int m_nColorTimer;
};

#endif // COLORMARKER_H
